package thread;

/**
 * 线程的优先级
 * 线程有十个优先级,分别用整数1-10表示,其中1为最低优先级,10为最高优先级
 * 5为默认优先级
 * 线程优先级越高的线程获取CPU时间片的概率越高
 */
public class PriorityDemo {
    public static void main(String[] args) {
        Thread min = new Thread(){
            @Override
            public void run() {
                for (int i = 0;i<10000;i++){
                    System.out.println("min");
                }
            }
        };

        Thread nor = new Thread(){
            @Override
            public void run() {
                for (int i = 0;i<10000;i++){
                    System.out.println("nor");
                }
            }
        };

        Thread max = new Thread(){
            @Override
            public void run() {
                for (int i = 0;i<10000;i++){
                    System.out.println("max");
                }
            }
        };


        min.setPriority(1);
        max.setPriority(10);
        min.start();
        nor.start();
        max.start();
    }
}











